package com.irs.irsforum.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * <p>
 *
 * </p>
 *
 * @author yihuili
 * @since 2020-01-18
 */
@Data
@TableName("forum_behavior")
public class Behavior extends Model<Behavior> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "user_id")
    private Long userId;
    @TableField("post_id")
    private Long postId;
    @TableField("creationTime")
    private Timestamp creationTime;
    /**
     * 0:发帖，回帖，收藏  1:看帖
     */
    @TableField("behavior_type")
    private Integer behaviorType;

    @TableField("problem_id")
    private Long problemId;

    @TableField("subject_id")
    private Long subjectId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Timestamp getCreationTime() {
        return creationTime;
    }

    public Behavior(Long userId, Long postId, Integer behaviorType, Timestamp creationTime) {
        this.userId = userId;
        this.postId = postId;
        this.behaviorType = behaviorType;
        this.creationTime = creationTime;
    }

    public Behavior(Long userId, Integer behaviorType) {
        this.userId = userId;
        this.behaviorType = behaviorType;
    }

    public Behavior(Long userId, Long postId, Timestamp creationTime, Integer behaviorType, Long problemId, Long subjectId) {
        this.userId = userId;
        this.postId = postId;
        this.creationTime = creationTime;
        this.behaviorType = behaviorType;
        this.problemId = problemId;
        this.subjectId = subjectId;
    }

    @Override
    protected Serializable pkVal() {
        return this.postId;
    }

    @Override
    public String toString() {
        return "Behavior{" +
                "userId=" + userId +
                ", postId=" + postId +
                ", creationTime=" + creationTime +
                ", behaviorType=" + behaviorType +
                ", problemId=" + problemId +
                ", subjectId=" + subjectId +
                '}';
    }
}
